package com.anxin.registerManagement.controller;

import com.anxin.registerManagement.bean.jo.PageJo;
import com.anxin.registerManagement.bean.jo.ReplySearchJo;
import com.anxin.registerManagement.bean.persist.Reply;
import com.anxin.registerManagement.service.ReplyService;
import com.anxin.registerManagement.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "回帖接口")
@RestController
@RequestMapping("/replies")
public class ReplyController {

    private static Logger logger = LoggerFactory.getLogger(ReplyController.class);

    @Autowired
    ReplyService replyService;


    @ApiOperation("查询回帖")
    @PostMapping("/search")
    public ResultUtil searchReply(@RequestBody ReplySearchJo replySearchJo) {
        logger.info("查询回帖");
        return ResultUtil.success(replyService.searchReply(replySearchJo));
    }


    @ApiOperation("添加回帖")
    @PostMapping("/add")
    public ResultUtil addReply(@RequestBody Reply reply) {
        logger.info("添加回帖：{}", reply);
        replyService.insert(reply);
        return ResultUtil.success();
    }

    @ApiOperation("删除回帖")
    @PostMapping("/delete")
    public ResultUtil deleteReply(@RequestParam("id") List<Integer> id) {
        logger.info("删除回帖：{}", id);
        return ResultUtil.success();
    }

}
